#include "stdafx.h"
#include "PoolSettings.h"
#include <windows.h> 
#include <stdio.h> 

CPoolSettings * CPoolSettings::_singleton = NULL;

CPoolSettings::CPoolSettings()
{

}

CPoolSettings * CPoolSettings::getInstance() 
{
  if (NULL == _singleton) {
    typedef void* (__cdecl *MYPROC)(); 
    MYPROC EntryPoint; 

    char szValue[256];
    GetProfileString("ConnectionPool", "FileName", "Settings.dll", szValue, sizeof(szValue));
    WriteProfileString("ConnectionPool", "FileName", szValue);

    HINSTANCE LoadMe = NULL;
    LoadMe = LoadLibrary(szValue);
    if (0 == LoadMe)
      OutputDebugString("Library failed to load or couldn't be found!\n");

    EntryPoint = (MYPROC)(GetProcAddress(LoadMe, "EntryPoint"));
    if (0 == EntryPoint)
      OutputDebugString("Function EntryPoint() not found in DLL!\n");

    _singleton = static_cast<CPoolSettings*>(EntryPoint());	
    //FreeLibrary(LoadMe); 
  }
  return _singleton;
}